home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / stdlib / system.c < prev   
Encoding:
C/C++ Source or Header  |  1997-09-09  |  922 b   |  50 lines

  1.  
  2. /*
  3.  *  SYSTEM.C        Dynamically check whether we are running under 1.3 or 1.4
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <exec/types.h>
  11. #include <exec/libraries.h>
  12. #include <stdlib.h>
  13.  
  14. #ifdef INCLUDE_VERSION        /*    doesn't exist in 1.3 */
  15. #include <dos/dostags.h>
  16. #include <clib/dos_protos.h>
  17. #endif
  18.  
  19. extern struct DosLibrary *DOSBase;
  20.  
  21. system(buf)
  22. const char *buf;
  23. {
  24.     int r;
  25.  
  26.     if (buf == NULL)
  27.     return(1);
  28.  
  29. #ifdef INCLUDE_VERSION
  30.     if (DOSBase->dl_lib.lib_Version >= 36) {
  31.     struct TagItem TI[] = {
  32.         SYS_Input , Input(),
  33.         SYS_Output, Output(),
  34.         _SystemBoolTag, _SystemBoolTagValue,
  35.         TAG_DONE, 0
  36.     };
  37.     r = System(buf, TI);
  38.     } else
  39. #endif
  40.     {
  41.     r = Execute(buf, NULL, NULL);
  42.     if (r == 0)
  43.         r = -1;
  44.     else if (r == -1)
  45.         r = 0;
  46.     }
  47.     return(r);
  48. }
  49.  
  50.